<html>
    <head>
        <title>Server Listing</title>
        <link type="text/css" rel="stylesheet" href="liststyle.css"/>
    </head>
    <body>
        <h2>Server List</h2>
        <div>
        <table>
            <tr><th>Name</th><th>Address</th><th>Last Update</th><th>Players</th><th>Locked</th><th>Version</th></tr>
            <tr>
<?php

$mysqli = new mysqli("jmpmain.com", "jmpmain_tracker", "_", "jmpmain_servertracker");
if(mysqli_connect_errno()){
  die("Could not resolve mysql connection.");
}

$result = $mysqli->query("delete from current where TIMESTAMPDIFF(MINUTE, pingtime, NOW()) > 5;");
$results = $mysqli->query("select * from current;");
$num_rows = mysqli_num_rows($results);
if($results){

    while($row = $results->fetch_object()){
        echo "<tr>";
        echo "<td><a href='$row->url'>$row->servername</a></td>";
        echo "<td>$row->ip:$row->port</td>";
        echo "<td>$row->pingtime</td>";
        echo "<td>$row->numplayers/$row->maxplayers</td>";
        echo "<td>$row->locked</td>";
        echo "<td>$row->version</td>";
        echo "</tr>";
    }
    
}
$mysqli->close();
?>
            </tr>
        </table>
     
        <div id="resultDiv">
<?php
    echo "$num_rows servers listed.";
?>
        </div>
        </div>
    </body>
</html>